package org.system.core.service.monitor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.system.core.domain.entity.SysLoginInfo;
import org.system.core.exception.ServiceException;
import org.system.core.mapper.monitor.SysLoginInfoMapper;
import org.system.core.utils.MessageUtils;

import java.util.List;

@Service
public class SysLoginInfoService {

    @Autowired
    private SysLoginInfoMapper sysLoginInfoMapper;

    public List<SysLoginInfo> selectLoginInfoList(SysLoginInfo loginInfo) {
        return sysLoginInfoMapper.selectLoginInfoList(loginInfo);
    }

    @Transactional
    public void deleteLoginInfoByIds(Long[] infoIds) {
        if (sysLoginInfoMapper.deleteLoginInfoByIds(infoIds) <= 0) {
            throw new ServiceException(MessageUtils.message("system.monitor.delete_error"));
        }
    }

    public void cleanLoginInfo() {
        sysLoginInfoMapper.cleanLoginInfo();
    }

}
